<?php
/* Variabeln abfangen */
$edit = $_GET['edit'];

/* Datenbank abfragen */
if (isset($_POST['save_nav']))
{
	$nav_bez = $_POST['nav_bez'];
	$nav_pos = $_POST['nav_pos'];
	$nav_link = $_POST['nav_link'];
	$nav_sbar = $_POST['nav_sbar'];
	$nav_unav = $_POST['nav_unav'];

	mysql_query("
	UPDATE navigation
	SET nav_bez = '$nav_bez', nav_pos = '$nav_pos', nav_link = '$nav_link', nav_sbar = '$nav_sbar', nav_unav = '$nav_unav'
	WHERE nav_id = ".$_GET['edit']
	);
}

$navi = mysql_query("
		SELECT *
		FROM navigation
		WHERE nav_id = ".$edit);

$link_bez = mysql_query("
		SELECT inh_id, inh_titel
		FROM inhalt");

/* Ausgabe Formular */
echo '<form action="index.php?id=nav_edit&amp;edit='.$edit.'" method="post" enctype="multipart/form-data">';
echo '<table border="1">';
if(mysql_num_rows($navi) > 0)
{
	echo '<tr>';
	echo '<td colspan="4"><h1>Navigationseditor</h1></td>';
	echo '</tr>';

	echo '<tr>';
	echo '<td>Bezeichnung</td>';
	echo '<td rowspan="7">&nbsp;</td>';
	echo '<td>';
	echo '<input name="nav_bez" type="text" maxlength="50" size="30" value="'.mysql_result($navi, 0, 'nav_bez').'" tabindex="1" />';
	echo '</td>';
	echo '<td>'.mysql_result($navi, 0, 'nav_id').'</td>';
	echo '</tr>';

	echo '<tr>';
	echo '<td>Position</td>';
	echo '<td><input name="nav_pos" type="text" maxlength="2" size="5" value="'.mysql_result($navi, 0, 'nav_pos').'" tabindex="2" /></td>';
	echo '<td>(1-10)</td>';
	echo '</tr>';

	echo '<tr>';
	echo '<td>Link</td>';
	echo '<td>';
	echo '<select name="nav_link" tabindex="3">';
	while($row = mysql_fetch_array($link_bez))
	{
		if($row['inh_id'] == mysql_result($navi, 0, 'nav_link'))
		{
			echo '<option value="'.$row['inh_id'].'" selected>'.$row['inh_id'].' | '.$row['inh_titel'].'</option>';
		}
		else
		{
			echo '<option value="'.$row['inh_id'].'">'.$row['inh_id'].' | '.$row['inh_titel'].'</option>';
		}
	}
	echo '</select>';
	echo '</td>';
	echo '<td>&nbsp;</td>';
	echo '</tr>';

	echo '<tr>';
	echo '<td>Sichtbar</td>';
	echo '<td>';
	echo '<select name="nav_sbar" tabindex="4">';
	if(mysql_result($navi, 0, 'nav_sbar') == 0)
	{
		echo '<option value="0" selected>0 | unsichtbar</option>';
		echo '<option value="1">1 | sichtbar</option>';
	}
	else
	{
		echo '<option value="0">0 | unsichtbar</option>';
		echo '<option value="1" selected>1 | sichtbar</option>';
	}
	echo '</select>';
	echo '</td>';
	echo '<td>&nbsp;</td>';
	echo '</tr>';

	echo '<tr>';
	echo '<td>Unternavigation</td>';
	echo '<td><input name="nav_unav" type="text" maxlength="2" size="5" value="'.mysql_result($navi, 0, 'nav_unav').'" tabindex="5" /></td>';
	echo '<td>(\'nav_id\' von Navigation)</td>';
	echo '</tr>';

	echo '<tr>';
	echo '<td>&nbsp;</td>';
	echo '<td colspan="2">';
	echo '<input type="submit" name="save_nav" value="Speichern" tabindex="6" />&nbsp;&nbsp;&nbsp;';
	echo '<a href="index.php?id=100">Abbrechen</a>';
	echo '</td>';
	echo '</tr>';
}
echo '</table>';
echo '</form>';
?>